/**
 * Created by chaoCheng on 2017/1/12.
 */
angular.module('playPlan', [])//模块名，注入到admin 主模块中
    .config(function PlayplanRoutes($stateProvider) {
        $stateProvider
            .state('playplan', {//路由名称
                parent: 'admin',
                url: '/playplan?{planName:string}&{groupName:string}&{startTime:string}&{endTime:string}',//url以及参数定义
                params: {
                    page: { value: 1, squash: true },//初始化url中的参数，不需要可以不写
                    size: { value: 10, squash: true }
                },
                views: {
                    'main@admin': {
                        templateUrl: 'admin/plan/list.html',//html地址
                        controller: 'PlayPlanController as vm',//控制器和他的别名
                        resolve: {
                            initialList: function(PlayPlan, $stateParams) {//从后台预加载的数据,Demo-注入的service
                                return PlayPlan.search({
                                    planName : $stateParams.planName,
                                    groupName:$stateParams.groupName,
                                    startTime:$stateParams.startTime,
                                    endTime:$stateParams.endTime,
                                    pageInfo: {
                                        pageSize: $stateParams.size,
                                        pageNumber: $stateParams.page
                                    }
                                })
                            }
                        }
                    }
                }
            })
            .state('playPlanAdd',{
                url: '/playPlanAdd',
                controller: 'PlayPlanAddController as vm',//控制器和他的别名
                templateUrl: 'admin/plan/playPlanAdd.html'
            })
            .state('playPlanUpdate',{
                url: '/playPlanUpdate?{planId:string}&{planName:string}',
                controller: 'PlayPlanAddController as vm',//控制器和他的别名
                templateUrl: 'admin/plan/playPlanAdd.html'
            })


    })

    .service('PlayPlan', PlayPlanModel)//声明

    .controller('PlayPlanController', PlayPlanController)
    .controller('PlayPlanAddController',PlayPlanAddController)



    .controller('PlayPlanInstanceCtrl', function ($scope, $uibModalInstance) {
        $scope.ok = function () {
            $uibModalInstance.close('ok');
        };

        $scope.cancel = function () {
            $uibModalInstance.close('cancel');
            //$uibModalInstance.dismiss('cancel');
        };
    });

